package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.YmtProductDescExtra;

public class YmtProductDescExtraWapper {
	SqlManager manage;

	public YmtProductDescExtraWapper() {
		manage = new SqlManager("intpro");
	}
	
	
	
	public YmtProductDescExtra selectByTemplateId(Integer templateId) throws InterruptedException{
		return (YmtProductDescExtra) manage.getSelectResults("com.ymttest.database.mapping.YmtProductDescExtraMapper.selectByPrimaryKey", templateId).get(0);
	}
	
	
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public List<Map> selectBySellerId(int sellerId) throws InterruptedException{
		return  manage.getSelectResults("com.ymttest.database.mapping.YmtProductDescExtraMapper.selectBySellerId", sellerId);
	}
	
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public List<Map<String,Object>> selectBySellerIdAndTypeId(int sellerId,int typeId) throws InterruptedException{
		 Map m = new HashMap();
		 m.put("SellerId", sellerId);
		 m.put("TemplateType", typeId);
		return  manage.getSelectResults("com.ymttest.database.mapping.YmtProductDescExtraMapper.selectBySellerIdAndTypeId", m);
	}
	
	
	public int deleteTemplate(int sellerId){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("SellerId", sellerId);
		int ret= manage.delete("com.ymttest.database.mapping.YmtProductDescExtraMapper.deleteTemplate", params);
		manage.commit();
		return ret;
	}
	
	
	
	
	public static void main(String[] args) throws InterruptedException {
		//System.out.println(new YmtProductDescExtraWapper().selectByTemplateId(1).getPicUrls());
		System.out.println(new YmtProductDescExtraWapper().deleteTemplate(20345997));
	}
}
